﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="FastSpring.Core.Model.Menu,FastSpring.Net.Core" table="Sys_Menu" lazy="false">
    <id name="MenuID" column="MenuID" type="Int32">
      <generator class="native" />
    </id>
    <property name="Mname" column="Mname"/>
    <property name="Murl" column="Murl"/>
    <property name="Mtarget" column="Mtarget"/>
    <property name="Morder" column="Morder"/>
    <property name="ModuleCode" column="ModuleCode"/>
    <property name="IsActive" column="IsActive"/>
    <many-to-one name="ParentMenu" 
     class="FastSpring.Core.Model.Menu,FastSpring.Net.Core" 
     cascade="none" 
     column="ParentID" 
     not-null="false"/>
    <bag name="SubMenus" cascade="none" inverse="false" lazy="false" order-by="Morder">
      <key column="ParentID"/>
      <one-to-many class="FastSpring.Core.Model.Menu,FastSpring.Net.Core" />
    </bag>
  </class>
  <query name="GetParentMenus">
    <![CDATA[from Menu menu where menu.ParentMenu.MenuID=1 ORDER BY menu.Morder]]>
  </query>
  <query name="GetAllMenus">
    <![CDATA[from Menu menu where menu.MenuID!=1 Order By menu.ParentMenu.MenuID,menu.Morder]]>
  </query>
  <query name="ParentMenuList">
    <![CDATA[Select menu.Mname,menu.MenuID from Menu menu where menu.ParentMenu.MenuID=1 ORDER BY menu.Morder]]>
  </query>
  <!-- 删除模块时查询此模块下是否有菜单存在 -->
  <query name="GetMenusOfMID">
    <![CDATA[from Menu menu WHERE menu.Module.MID=:ParentID]]>
  </query>
  <!-- 删除菜单时查询此菜单下是否有子菜单存在 -->
  <query name="GetMenusOfParentMenuID">
    <![CDATA[from Menu menu WHERE menu.ParentMenu.MenuID=:ParentID]]>
  </query>
</hibernate-mapping>

